import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
const resolve = (dir: string) => path.resolve(__dirname, dir); // 获取绝对路径

// https://vitejs.dev/config/
export default defineConfig({
  appType: 'mpa',
  resolve: {
    alias: {
      '@': resolve('./src/'),
      '@assets': resolve('./src/assets'),
      '@styles': resolve('./src/styles'),
    },
  },
  plugins: [vue()],
  server: {
    host: '0.0.0.0',
    port: 9527,
  },
  root: 'src/pages',
  base: './',
  build: {
    outDir: '../../dist',
    assetsDir: '../../assets',
    rollupOptions: {
      // ...
      // input:"src/index.js"
      input: {
        index: resolve('src/pages/index/index.html'),
        main: resolve('src/pages/main/index.html'),
      },
      output: {
        chunkFileNames: '[name]/js/[hash].js',
        entryFileNames: '[name]/js/[hash].js',
        assetFileNames: 'static/[hash].[ext]',
      },
    },
    emptyOutDir: true,
  },
});
